package session

import (
	"strconv"
	"time"
)

type CallMethod string

const (
	CALL_TYPE_START  CallMethod = ""
	CALL_TYPE_NOTIFY CallMethod = "notify"
	CALL_TYPE_IN     CallMethod = "in"
	CALL_TYPE_BACK   CallMethod = "back"
	CALL_TYPE_GUESS  CallMethod = "guess" //预测外呼
	CALL_TYPE_OUT    CallMethod = "out"
	CALL_TYPE_DIRECT CallMethod = "dout"
)

type SessionCommand int

const (
	SESSION_COMMAND SessionCommand = iota
	SESSION_COMMAND_GETDTMF
	SESSION_COMMAND_PLAY
	SESSION_COMMAND_PLAY_SERVICEID
	SESSION_COMMAND_RECORD
	SESSION_COMMAND_HANGHUP
	SESSION_COMMAND_HANGHUP_API
	SESSION_COMMAND_END
)

type response struct {
	CallId     string `json:"callId"`
	Result     int    `json:"callResult"`
	AnswerTime string `json:"calledPickTime"`
	StatusCode string `json:"disconnectValue"`
	CallTime   int    `json:"callTime"`
}

func timeStampToTime(timeStamp string) time.Time {

	t, err := strconv.Atoi(timeStamp)
	if err != nil {
		return time.Now()
	}
	tSec := int64(t / 1000000)
	tMsec := int64(t % 1000000 * 1000)

	return time.Unix(tSec, tMsec)
}
